package day19;

import java.util.Scanner;

/**
 * @author tongchen
 * @create 2023-03-26 23:45
 */
public class Main1 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String s1=scanner.nextLine();
        String s2=scanner.nextLine();
        int mLength=0;
        String res="";
        for(int i=0;i<s1.length();++i){
            for (int j = 0; j <s2.length() ; j++) {
                int k=0;
                while((i+k)<s1.length()&&(j+k)<s2.length()&&s1.charAt(i+k)==s2.charAt(j+k)){
                    k++;
                }
                if(k>mLength){
                    mLength=k;
                    res=s2.substring(j, j+k);
                }

            }
        }
        System.out.println(res);

    }
}
